package com.huangkailong.designpattern.composite.lucence;

/**
 * 单一课程信息.
 *
 * @author huangkl
 * @since 1.0.0
 */
public class SingleCourse implements Course {
    private final String name;
    private final Double price;

    /**
     * 构造函数.
     *
     * @param name  名称
     * @param price 价格
     */
    public SingleCourse(String name, Double price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public void showInfo(int level) {
        for (int i = 0; i < level; i++) {
            System.out.print("\t");
        }
        System.out.printf("+-%s(￥%.2f)\n", name, price);
    }

    @Override
    public String getCourseName() {
        return name;
    }

    @Override
    public Double getPrice() {
        return price;
    }
}
